function t(t, e, n) {
    return e in t ? Object.defineProperty(t, e, {
        value: n,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[e] = n, t;
}

var e = function() {
    function t(t, e) {
        var n = [], r = !0, i = !1, o = void 0;
        try {
            for (var a, u = t[Symbol.iterator](); !(r = (a = u.next()).done) && (n.push(a.value), 
            !e || n.length !== e); r = !0) ;
        } catch (t) {
            i = !0, o = t;
        } finally {
            try {
                !r && u.return && u.return();
            } finally {
                if (i) throw o;
            }
        }
        return n;
    }
    return function(e, n) {
        if (Array.isArray(e)) return e;
        if (Symbol.iterator in Object(e)) return t(e, n);
        throw new TypeError("Invalid attempt to destructure non-iterable instance");
    };
}(), n = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
    return typeof t;
} : function(t) {
    return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
}, r = {
    Div: function(t, e) {
        t = parseFloat(t), e = parseFloat(e);
        var n, r, i = 0, o = 0;
        try {
            i = t.toString().split(".")[1].length;
        } catch (t) {}
        try {
            o = e.toString().split(".")[1].length;
        } catch (t) {}
        return n = Number(t.toString().replace(".", "")), r = Number(e.toString().replace(".", "")), 
        this.Mul(n / r, Math.pow(10, o - i));
    },
    Add: function(t, e) {
        e = parseFloat(e);
        var n, r, i;
        try {
            n = t.toString().split(".")[1].length;
        } catch (t) {
            n = 0;
        }
        try {
            r = e.toString().split(".")[1].length;
        } catch (t) {
            r = 0;
        }
        return i = Math.pow(100, Math.max(n, r)), (this.Mul(t, i) + this.Mul(e, i)) / i;
    },
    Sub: function(t, e) {
        t = parseFloat(t), e = parseFloat(e);
        var n, r, i, o;
        try {
            n = t.toString().split(".")[1].length;
        } catch (t) {
            n = 0;
        }
        try {
            r = e.toString().split(".")[1].length;
        } catch (t) {
            r = 0;
        }
        return i = Math.pow(10, Math.max(n, r)), o = n >= r ? n : r, ((this.Mul(t, i) - this.Mul(e, i)) / i).toFixed(o);
    },
    Mul: function(t, e) {
        t = parseFloat(t), e = parseFloat(e);
        var n = 0, r = t.toString(), i = e.toString();
        try {
            n += r.split(".")[1].length;
        } catch (t) {}
        try {
            n += i.split(".")[1].length;
        } catch (t) {}
        return Number(r.replace(".", "")) * Number(i.replace(".", "")) / Math.pow(10, n);
    }
}, i = function(t, e) {
    "string" == typeof t && (e = t, t = {});
    var r = t.title || "", i = t.icon || "none", o = t.endtime || 2e3;
    if (r && wx.showToast({
        title: r,
        icon: i,
        duration: o
    }), void 0 != e) if ("object" == (void 0 === e ? "undefined" : n(e))) {
        var a = e.tab || 1, u = e.url || "";
        switch (a) {
          case 1:
            setTimeout(function() {
                wx.switchTab({
                    url: u
                });
            }, o);
            break;

          case 2:
            setTimeout(function() {
                wx.navigateTo({
                    url: u
                });
            }, o);
            break;

          case 3:
            setTimeout(function() {
                wx.navigateBack({
                    delta: parseInt(u)
                });
            }, o);
            break;

          case 4:
            setTimeout(function() {
                wx.reLaunch({
                    url: u
                });
            }, o);
            break;

          case 5:
            setTimeout(function() {
                wx.redirectTo({
                    url: u
                });
            }, o);
        }
    } else "function" == typeof e ? setTimeout(function() {
        e && e();
    }, o) : setTimeout(function() {
        wx.navigateTo({
            url: e
        });
    }, r ? o : 0);
}, o = function(t, e) {
    for (var n = 0, r = 1, i = 0, o = [], a = 0; a < t.length; a++) t.charCodeAt(a) > 255 ? (n += 2) > r * e && (n++, 
    o.push(t.slice(i, a)), i = a, r++) : ++n > r * e && (o.push(t.slice(i, a)), i = a, 
    r++);
    return o.push(t.slice(i, t.length)), [ n, o, r ];
};

module.exports = {
    formatTime: function(t) {
        var e = t.getFullYear(), n = t.getMonth() + 1, r = t.getDate(), i = t.getHours(), o = t.getMinutes(), a = t.getSeconds();
        return {
            week: week,
            year: e,
            month: n,
            day: r,
            hour: i,
            minute: o,
            second: a
        };
    },
    $h: r,
    Tips: i,
    SplitArray: function(t, e) {
        if ("object" != (void 0 === t ? "undefined" : n(t))) return [];
        void 0 === e && (e = []);
        for (var r = 0; r < t.length; r++) e.push(t[r]);
        return e;
    },
    ArrayRemove: function(t, e, n) {
        var r = [];
        if (t instanceof Array) for (var i = 0; i < t.length; i++) "number" == typeof e && t[e] != i ? r.push(t[i]) : "string" == typeof e && t[i][e] != n && r.push(t[i]);
        return r;
    },
    PosterCanvas: function(t, n, r, a) {
        wx.showLoading({
            title: "海报生成中",
            mask: !0
        });
        var u = wx.createCanvasContext("myCanvas");
        u.clearRect(0, 0, 0, 0), wx.getImageInfo({
            src: t[0],
            success: function(i) {
                var c = i.width, s = i.height;
                u.drawImage(t[0], 0, 0, c, s), u.drawImage(t[1], 0, 0, c, c), u.save(), u.arc(130, 1080, 90, 0, 2 * Math.PI), 
                u.clip(), u.drawImage(t[2], 40, 990, 180, 180), u.restore();
                var l = o(n, 40), f = e(l, 3), h = (f[0], f[1]), g = f[2];
                if (g > 2) {
                    g = 2;
                    var p = h.slice(0, 2);
                    p[p.length - 1] += "……", h = p;
                }
                u.setTextAlign("center"), u.setFontSize(32);
                for (var d = 0; d < h.length; d++) u.fillText(h[d], c / 2, 820 + 41.6 * d);
                u.setTextAlign("center"), u.setFontSize(48), u.setFillStyle("red"), u.fillText("￥" + r, c / 2, 901.6), 
                u.draw(!0, function() {
                    wx.canvasToTempFilePath({
                        canvasId: "myCanvas",
                        fileType: "png",
                        destWidth: c,
                        destHeight: s,
                        success: function(t) {
                            wx.hideLoading(), a && a(t.tempFilePath);
                        }
                    });
                });
            },
            fail: function() {
                wx.hideLoading(), i({
                    title: "无法获取图片信息"
                });
            }
        });
    },
    AnimationNumber: function(e, n, i, o) {
        for (var a = r.Sub(n, e), u = Math.abs(a), c = u < 6 ? u : 6, s = u < 6 ? 1 : Math.floor(a / 6), l = 0; l < c; l += 1) !function(n) {
            setTimeout(function() {
                i.setData(t({}, o, r.Add(e, s))), n == c - 1 && i.setData(t({}, o, r.Add(e, a)));
            }, 100 * (n + 1));
        }(l);
    },
    getUrlParams: function(t, e, n) {
        if ("string" != typeof t) return {};
        e = e || "&", n = n || "=";
        var r = {};
        if (-1 !== t.indexOf(e)) {
            t = t.split(e);
            for (var i in t) -1 !== t[i].indexOf(n) && (r[(o = t[i].split(n))[0]] = o[1]);
        } else {
            if (-1 === t.indexOf(n)) return t;
            var o = t.split(n);
            r[o[0]] = o[1];
        }
        return r;
    },
    getCodeLogin: function(t) {
        wx.login({
            success: function(e) {
                t(e);
            }
        });
    },
    wxgetUserInfo: function() {
        return new Promise(function(t, e) {
            wx.getUserInfo({
                lang: "zh_CN",
                success: function(e) {
                    t(e);
                },
                fail: function(t) {
                    e(t);
                }
            });
        });
    }
};